#include("/front/teacher/_layout.html")
#@layout()
#define layoutImportcss()
    <link rel="stylesheet" href="/front/css/framework7-icons.css">
#end
#define layoutHead()
<title>家长信息</title>
#end
#define layoutHome()

	<div class="page-content people-page-content infinite-scroll-content">
	<div class="navbar">
		<div class="navbar-inner toolbstyle">
			<div class="left">
				<a href="javascript:history.back()" class="link back">
					<i class="icon icon-back"></i>
				</a>
			</div>
			<div class="title">家长信息</div>
			<div class="right"></div>
		</div>
	</div>
		<div class="people-list" style="margin-top:3px;">
			<div class="list">
				<ul id="ul_parents">
				</ul>
			</div>
		</div>                   
	</div>
#end
#define layoutImportjs()
#end
#define layoutScript()
<script type="text/javascript">
	var stu_id = getUrlParam('stuid');
	sendPost('/front/teacher/students/getParents?stuid='+stu_id, null, function(res){
		if (res.code == 200){
			if (isJsonProps(res, 'listparents')){
				bindParents(res.listparents);
			}
		}else{
			alert(res.msg);
		}
	});
	
	function bindParents(list_data){
		var shtml = '';
		for (var i = 0; i < list_data.length; i++) {
			var jdata = list_data[i];
			shtml += getParentsHtml(jdata);
		}
		$$('#ul_parents').append(shtml);
	}
	function getParentsHtml(jdata){
		var lihtml = `
			<li>
				<a class="item-content ac-1">
					<div class="item-media">
						<span class="head-portrait people-head"><img src="${formatUserHeadImage(jdata.user_img)}"></span>
					</div>
					<div class="item-inner">
						<div class="item-title">${jdata.student_name+jdata.kindred_name}</div>
						<div class="item-after item-after-student">
							<i class="f7-icons" onclick="callTelphone('${jdata.parent_mobile}')">phone_fill</i>
							<i class="f7-icons" onclick="delParent(${jdata.parent_id})">trash_fill</i>
						</div>
					</div>
				</a>
			</li>
		`;
		return lihtml;
	}
	function delParent(pid){
		app.dialog.confirm('', '确定要删除吗?', function () {
			sendPost('/front/teacher/students/delParent?stuid='+stu_id+'&pid='+pid, null, function(res){
				//console.log(res);
				alert(res.msg);
				if (res.code == 200){
					window.location.reload();
				}
			});
		});
	}
</script>
#end
